/*
 * @Date         : 2024-05-21 21:57:35 星期2
 * @Author       : xut
 * @Description  :
 */
import { Module } from '@nestjs/common';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { HERO_PACKAGE } from './hero.constant';
import { HeroServiceController } from './hero-service.controller';
import { HeroClientController } from './hero-client.controller';
import { join } from 'path';

@Module({
  imports: [
    // grpc 客户端注册方式之一
    ClientsModule.register([
      {
        name: HERO_PACKAGE,
        transport: Transport.GRPC,
        options: {
          package: 'hero', // 可以是字符串 hero，也可以是数组多外包 ['hero', 'hero2']
          protoPath: [join(__dirname, './hero.proto')], // 可以是字符串形式单个 './hero/hero.proto，也可以是数组形式多个 ['./hero/hero.proto', './hero/hero2.proto']
        },
      },
    ]),
  ],
  controllers: [HeroServiceController, HeroClientController],
})
export class HeroModule {}
